package com.server.api.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.server.api.dao.${className}Dao;
import com.server.api.dto.${className}DTO;
import com.server.api.service.${className}Service;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @Description: ${tableComment}业务层实现类
* @Author: wuming
*/
@Service("${unClassName}Service")
public class ${className}ServiceImpl extends ServiceImpl<${className}Dao, ${className}DTO> implements ${className}Service {

    @Override
    public Page<${className}DTO> basePage(${className}DTO ${unClassName}DTO) {
        if (null != ${unClassName}DTO.getCurrent() && null != ${unClassName}DTO.getPageSize())
            ${unClassName}DTO.setCurrent((${unClassName}DTO.getCurrent() - 1) * ${unClassName}DTO.getPageSize());
        List<${className}DTO> list = this.baseMapper.findList(${unClassName}DTO);
        int count = this.baseMapper.findPageCount(${unClassName}DTO);
        Page<${className}DTO> page = new Page<>();
        page.setTotal(count);
        page.setRecords(list);
        return page;
    }

    @Override
    public ${className}DTO find(${className}DTO ${unClassName}DTO) { return this.baseMapper.find(${unClassName}DTO); }

}
